#ifndef STOPWATCH_H
#define STOPWATCH_H

#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#include "list.h"

#ifdef __cplusplus
extern "C" {
#endif

struct mark {
	time_t time; // time relative to effective start time
	time_t real_time; // absolute, real time
	char *name;
};

typedef struct {
	time_t start_time;
	list_t *marks;

	time_t effective_start_time;
	time_t pause_time;
} stopwatch_t;

stopwatch_t *stopwatch_create();
void stopwatch_start(stopwatch_t *);
time_t stopwatch_start_time();
time_t stopwatch_effective_start_time();
void stopwatch_pause(stopwatch_t *);
time_t stopwatch_unpause(stopwatch_t *);

void stopwatch_mark(stopwatch_t *, char *);
struct mark *stopwatch_get_mark(stopwatch_t *, char *);
time_t stopwatch_get_delay(stopwatch_t *, char *);
time_t stopwatch_get_absolute_delay(stopwatch_t *, char *);
time_t stopwatch_get_real_time(stopwatch_t *, char *);

void stopwatch_destroy(stopwatch_t *);

#ifdef __cplusplus
}
#endif

#endif /* !STOPWATCH_H */
